// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace FederationMetadataEditor
{
    using System.Configuration;

    ////<SelfSTS host="localhost:8000" signingcertificate="CN=">
    //// //WILL DO THIS LATER <signingcertificate subject="CN=" | bits="sjhaskjhajkajfgafjha" password="xyz">

    ////<Claims>
    ////    <Claim type="http://blah" displayname="blah" value="">
    ////    <Claim type="http://blah" displayname="blah" value="">
    ////</Claims>
    ////</SelfSTS>

    public class SelfSTSSection : ConfigurationSection
    {
        public static SelfSTSSection Current
        {
            get
            {
                var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var section = config.GetSection("SelfSTSSettings") as SelfSTSSection;
                
                return section;
            }
        }

        [ConfigurationProperty("port", DefaultValue = "8000", IsRequired = true, IsKey = false)]
        public string Port
        {
            get
            {
                return (string)this["port"];
            }

            set
            {
                this["port"] = value;
            }
        }

        [ConfigurationProperty("signingcertificate", IsRequired = false, IsKey = false)]
        public string SigningCertificate
        {
            get
            {
                return (string)this["signingcertificate"];
            }

            set
            {
                this["signingcertificate"] = value;
            }
        }

        [ConfigurationProperty("signingcertificatepassword", IsRequired = false, IsKey = false)]
        public string SigningCertificatePassword
        {
            get
            {
                return (string)this["signingcertificatepassword"];
            }

            set
            {
                this["signingcertificatepassword"] = value;
            }
        }

        [ConfigurationProperty("issuername", IsRequired = true, IsKey = false)]
        public string IssuerName
        {
            get
            {
                return (string)this["issuername"];
            }

            set
            {
                this["issuername"] = value;
            }
        }

        [ConfigurationProperty("claims", IsDefaultCollection = false)]
        public ClaimsCollection Claims
        {
            get
            {
                ClaimsCollection claimsCollection = (ClaimsCollection)base["claims"];
                return claimsCollection;
            }
        }

        protected override void DeserializeSection(System.Xml.XmlReader reader)
        {
            base.DeserializeSection(reader);

            // You can add custom processing code here.
        }

        protected override string SerializeSection(ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
        {
            string s = base.SerializeSection(parentElement, name, saveMode);

            // You can add custom processing code here.
            return s;
        }
    }
}